<?php

namespace Tbqphplib\Article\Controllers;

use Illuminate\Support\Facades\DB;

class ArticleController extends \App\Http\Controllers\Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        // $this->middleware('auth');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function index()
    {
        $articles = DB::table('articles')->latest()->paginate(2);
        return view('tbqphplib-article::home', ['articles' => $articles]);
    }

    public function view(string $uuid)
    {
        $article = DB::table('articles')->where('uuid', $uuid)->first();
        return view('tbqphplib-article::article/view', ['article' => $article]);
    }
}
